import { DtoOmitType, classDto2Zod, formatDate } from "src/utils";
import { PerformanceDto } from "../dto";
import { ApiProp } from "src/decorator/swagger";
import { z } from "zod";

/** 统计信息/性能指标 */
export class PerformanceVo extends DtoOmitType(PerformanceDto, [
  'createTime', 'updateTime',
]) {
  @ApiProp({ desc: '创建时间', default: '2023-12-30 13:20:45', zodType: z.date().or(z.string())
    .transform(date => (Object.prototype.toString.call(date)==='[object Date]') ? formatDate(date) : date)
  })
  createTime!: string

  @ApiProp({ desc: '更新时间', default: '2023-12-30 13:20:45', zodType: z.date().or(z.string())
    .transform(date => (Object.prototype.toString.call(date)==='[object Date]') ? formatDate(date) : date)
  })
  updateTime!: string
}

export const PerformanceVoZod = classDto2Zod(PerformanceVo);